package com.cjc.okhttp;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class test2 {
	public static void main(String[] args) throws ParseException {
		String begin = "2011-02-03";
		String end = "2011-03-23";
		int step = 30;
		List<String> list = getJulianDays(begin, end, step);
		for (String date : list) {
			System.out.println(date);
		}
	}

	private static List<String> getJulianDays(String beginDate, String endDate, int step) throws ParseException {
		List<String> dateList = new ArrayList<String>();
		Calendar cal = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMdd");
		Date start = sdf.parse(beginDate);
		int end = Integer.parseInt(sdf2.format(sdf.parse(endDate)));
		cal.setTime(start);
		while (Integer.parseInt(sdf2.format(cal.getTime())) <= end) {
			dateList.add(sdf.format(cal.getTime()));
			cal.add(Calendar.DATE, step + 1);
		}
		return dateList;
	}
}
